package com.anjiplus.template.gaea.business;

import com.anji.plus.gaea.annotation.enabled.EnabledGaeaConfiguration;
import com.anjiplus.template.gaea.business.modules.opcua.controller.OpcClientController;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 业务模板
 * @author lr
 * @since 2021-02-03
 */
@EnabledGaeaConfiguration
@SpringBootApplication(scanBasePackages = {
        "com.anjiplus.template.gaea",
        "com.anji.plus"
})
@MapperScan(basePackages = {
        "com.anjiplus.template.gaea.business.modules.*.dao",
        "com.anjiplus.template.gaea.business.modules.*.**.dao",
        "com.anji.plus.gaea.*.module.*.dao"
})
@EnableSwagger2
public class ReportApplication {

    private static OpcClientController opcUaClientController;

    public static void main( String[] args ) throws Exception {
//        SpringApplication.run(ReportApplication.class);

        ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(ReportApplication.class,args);
        //解决service不能注入的问题
        OpcClientController.setApplicationContext(configurableApplicationContext);

        //获取bean，从而在启动的时候就得到@Value 中的值
        opcUaClientController= configurableApplicationContext.getBean(OpcClientController.class);
        //不能new 否则就不能取得@Value 中的值
//        OpcClientController opcUaClientController = new OpcClientController();
        opcUaClientController.start();
    }
}
